package com.soft.cqlinglong.oto.web.permission;

import com.alibaba.fastjson.JSON;
import com.soft.cqlinglong.oto.dao.model.TSUser;
import com.soft.cqlinglong.oto.service.permission.TSUserService;
import com.soft.cqlinglong.oto.web.BaseController;
import com.soft.cqlinglong.oto.web.interceptor.Permission;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.util.HashMap;
import java.util.Map;

/**
 * 账号表， 用于登录或者人员查询
 *
 * @author 黄学乾 778142659@qq.com
 * @create 2017-07-16 20:18
 **/
@Controller
@RequestMapping("system/tsUser")
public class TsUserController extends BaseController {
    @Autowired
    private TSUserService tsUserService;

    @Permission
    @RequestMapping({"nositemesh/tsUserList", "sitemesh/tsUserList"})
    public ModelAndView tsUserList() {
        ModelAndView tsUser = new ModelAndView("permission/tsUserList");
        return tsUser;
    }


    /**
     * @param tsUser 保存用户信息
     */
    @Permission
    @RequestMapping({"sitemesh/saveTsUser", "nositemesh/saveTsUser"})
    public Map saveTsUser(TSUser tsUser) {
        Map<String, Object> resMap = new HashMap<String, Object>();
        try {
            logger.info("saveTsUser--->start:" + JSON.toJSONString(tsUser));
            tsUser = tsUserService.saveTSUser(tsUser, null);
            logger.info("saveTsUser--->end:" + JSON.toJSONString(tsUser));
        } catch (Exception e) {
            e.printStackTrace();
        }
        return resMap;
    }


}
